﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICeFramework.Common.DataLayer.Enums;
using ICeFramework.Common.DataLayer;
using ICeFramework.DataAccess.DataLayer.Interfaces;
using ICeFramework.DataAccess.DataLayer.Enums;

namespace ICeFramework.DataAccess.DataLayer
{
    public abstract class DBCommand : IDbCommand
    {
        protected EntityType _entityType = EntityType.Table;
        #region public EntityType EntityType
        /// <summary>
        /// Get/Sets the EntityType of the DBCommand
        /// </summary>
        /// <value></value>
        public EntityType EntityType
        {
            get { return _entityType; }
            set { _entityType = value; }
        }
        #endregion

        protected string _entityName;
        public string EntityName
        {
            get { return _entityName; }
            set { _entityName = value; }
        }

        protected DataParameterCollection _parameters = new DataParameterCollection();
        public DataParameterCollection Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }

        private EntityFilter _filter;
        public EntityFilter Filter
        {
            get { return _filter; }
            set { _filter = value; }
        }

        private EntityOrder _order;
        public EntityOrder Order
        {
            get { return _order; }
            set { _order = value; }
        }

        protected string _commandText;
        public string CommandText
        {
            get { return _commandText; }
            set { _commandText = value; }
        }

        private bool _count = false;
        public bool Count
        {
            get { return _count; }
            set { _count = value; }
        }

        private System.Data.IDbTransaction _transaction;
        public System.Data.IDbTransaction Transaction
        {
            get { return _transaction; }
        }

        public abstract DBCommandType CommandType { get; }

        public DBCommand(EntityFilter filter, EntityOrder order, string tableName, System.Data.IDbTransaction transaction)
        {
            _filter = filter;
            _order = order;
            _entityName = tableName;
            _transaction = transaction;
        }

        public DBCommand(string tableName, System.Data.IDbTransaction transaction)
        {
            _entityName = tableName;
            _transaction = transaction;
        }

        public abstract string BuildCommandText(string parameterToken);
        public abstract string BuildPagingCommandText(string parameterToken, int pageIndex, int pageSize);

    }
}
